/*! ******************************************************************************
 *
 * Created on 2021年11月30日
 *
 * Copyright(c) YuZhou Big Data Laboratory CO.,Ltd, 2022.  All rights reserved.
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

package org.pentaho.di.ui.spoon.navigation.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.TreeItem;
import org.pentaho.di.ui.core.gui.GUIResource;
import org.pentaho.di.ui.spoon.navigation.SpoonRef;

/**
 * 
 * 所有SubTree抽象父类，提供对Spoon引用、Subtree父容器和自身视图的访问。
 * 
 * @author hs@yzbdl.ac.cn
 *
 */
public abstract class Subtree {

	/**
	 * 持有对Spoon的引用
	 */
	private SpoonRef spoonRef;

	/**
	 * 父容器
	 */
	private MetaTree parent;

	/**
	 * 自身视图
	 */
	private TreeItem view;

	public Subtree(MetaTree parent) {
		super();
		this.parent = parent;
		this.spoonRef = parent.getSpoonRef();
		buildView();
	}

	/**
	 * 生成视图
	 */
	public void buildView() {
		this.view = new TreeItem(parent.getView(), SWT.NONE);
		this.view.setText(getName());
		this.view.setImage(GUIResource.getInstance().getImageFolder());
	}

	/**
	 * 获取子树名称
	 * 
	 * @return 子树名称
	 */
	public abstract String getName();

	public SpoonRef getSpoonRef() {
		return spoonRef;
	}

	public MetaTree getParent() {
		return parent;
	}

	public TreeItem getView() {
		return view;
	}

}
